<script lang="ts" setup>
import { ref } from 'vue'
import {
  User,
  Expand,
  Tickets,
  Fold,
  Edit,
  School,
  Files,
  DocumentChecked,
  PieChart
} from '@element-plus/icons-vue'
import teacherPageJumper from '../utils/router/TeacherPageJumper'

const isCollapse = ref(false)
const handleOpen = (key: string, keyPath: string[]) => {
  //console.log(key, keyPath)
}
const handleClose = (key: string, keyPath: string[]) => {
  //console.log(key, keyPath)
}
const collapseChange = ()=>{
  isCollapse.value = !isCollapse.value
}
</script>

<template>
  <div class="main-container">
    <el-menu
        default-active="1-1"
        class="el-menu-vertical-demo"
        :collapse="isCollapse"
        @open="handleOpen"
        @close="handleClose"
    >
      <el-menu-item @click="collapseChange">
        <el-icon v-if="isCollapse"><Expand /></el-icon>
        <el-icon v-else><Fold /></el-icon>
        <span>收起</span>
      </el-menu-item>

      <el-sub-menu index="1">
        <template #title>
          <el-icon><Tickets /></el-icon>
          <span>习题管理</span>
        </template>
        <el-menu-item index="1-1" @click="teacherPageJumper.jumpToNewTask()">
          <el-icon><Edit /></el-icon>
          <span>发布习题任务</span>
        </el-menu-item>
        <el-menu-item index="1-2" @click="teacherPageJumper.jumpToTaskCorrect()">
          <el-icon><DocumentChecked /></el-icon>
          <span>智能批改结果</span>
        </el-menu-item>
      </el-sub-menu>

      <el-sub-menu index="2">
        <template #title>
          <el-icon><PieChart /></el-icon>
          <span>AI学情分析</span>
        </template>
        <el-menu-item index="2-1" @click="teacherPageJumper.jumpToClassAnalysis()">
          <el-icon><School /></el-icon>
          <span>班级概况</span>
        </el-menu-item>
        <el-menu-item index="2-2" @click="teacherPageJumper.jumpToStudentAnalysis()">
          <el-icon><Files /></el-icon>
          <span>学生分析</span>
        </el-menu-item>
      </el-sub-menu>

      <el-menu-item index="3" @click="teacherPageJumper.jumpToClassManage()">
        <el-icon><School /></el-icon>
        <span>班级管理</span>
      </el-menu-item>

      <el-menu-item index="4" @click="teacherPageJumper.jumpToUserCenter()">
        <el-icon><User /></el-icon>
        <span>教师用户中心</span>
      </el-menu-item>
    </el-menu>
    <router-view class="children-router-view"/>
  </div>
</template>

<style scoped>
.main-container{
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
::v-deep .el-menu{
  height: 100%;
}
.children-router-view{
  flex: 1;
  height: 100%;
}
</style>